load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "snap_client",
    srcs = [
        "client.go",
        "import.go",
        "pipeline_items.go",
        "pitr_collector.go",
        "placement_rule_manager.go",
        "systable_restore.go",
        "tikv_sender.go",
    ],
    importpath = "github.com/pingcap/tidb/br/pkg/restore/snap_client",
    visibility = ["//visibility:public"],
    deps = [
        "//br/pkg/checkpoint",
        "//br/pkg/checksum",
        "//br/pkg/conn",
        "//br/pkg/conn/util",
        "//br/pkg/errors",
        "//br/pkg/glue",
        "//br/pkg/logutil",
        "//br/pkg/metautil",
        "//br/pkg/pdutil",
        "//br/pkg/restore",
        "//br/pkg/restore/internal/import_client",
        "//br/pkg/restore/internal/prealloc_db",
        "//br/pkg/restore/internal/prealloc_table_id",
        "//br/pkg/restore/split",
        "//br/pkg/restore/utils",
        "//br/pkg/storage",
        "//br/pkg/stream",
        "//br/pkg/streamhelper",
        "//br/pkg/summary",
        "//br/pkg/utils",
        "//br/pkg/version",
        "//pkg/bindinfo",
        "//pkg/config/kerneltype",
        "//pkg/domain",
        "//pkg/domain/infosync",
        "//pkg/kv",
        "//pkg/meta",
        "//pkg/meta/model",
        "//pkg/metrics",
        "//pkg/parser/ast",
        "//pkg/parser/mysql",
        "//pkg/statistics/handle",
        "//pkg/statistics/handle/types",
        "//pkg/tablecodec",
        "//pkg/util",
        "//pkg/util/codec",
        "//pkg/util/engine",
        "//pkg/util/redact",
        "//pkg/util/table-filter",
        "@com_github_google_uuid//:uuid",
        "@com_github_opentracing_opentracing_go//:opentracing-go",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_pingcap_kvproto//pkg/brpb",
        "@com_github_pingcap_kvproto//pkg/import_sstpb",
        "@com_github_pingcap_kvproto//pkg/kvrpcpb",
        "@com_github_pingcap_kvproto//pkg/metapb",
        "@com_github_pingcap_log//:log",
        "@com_github_tikv_client_go_v2//oracle",
        "@com_github_tikv_client_go_v2//util",
        "@com_github_tikv_pd_client//:client",
        "@com_github_tikv_pd_client//http",
        "@io_etcd_go_etcd_client_v3//:client",
        "@org_golang_google_grpc//codes",
        "@org_golang_google_grpc//keepalive",
        "@org_golang_google_grpc//status",
        "@org_golang_x_exp//maps",
        "@org_golang_x_sync//errgroup",
        "@org_uber_go_multierr//:multierr",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "snap_client_test",
    timeout = "short",
    srcs = [
        "client_test.go",
        "export_test.go",
        "import_test.go",
        "main_test.go",
        "pipeline_items_test.go",
        "pitr_collector_test.go",
        "placement_rule_manager_test.go",
        "systable_restore_test.go",
        "tikv_sender_test.go",
    ],
    embed = [":snap_client"],
    flaky = True,
    shard_count = 42,
    deps = [
        "//br/pkg/checkpoint",
        "//br/pkg/errors",
        "//br/pkg/glue",
        "//br/pkg/gluetidb",
        "//br/pkg/metautil",
        "//br/pkg/mock",
        "//br/pkg/restore",
        "//br/pkg/restore/internal/import_client",
        "//br/pkg/restore/split",
        "//br/pkg/restore/utils",
        "//br/pkg/storage",
        "//br/pkg/stream",
        "//br/pkg/utils",
        "//pkg/domain",
        "//pkg/kv",
        "//pkg/meta",
        "//pkg/meta/model",
        "//pkg/parser/ast",
        "//pkg/parser/mysql",
        "//pkg/session",
        "//pkg/statistics/handle/types",
        "//pkg/tablecodec",
        "//pkg/testkit",
        "//pkg/testkit/testsetup",
        "//pkg/types",
        "//pkg/util",
        "//pkg/util/codec",
        "@com_github_google_uuid//:uuid",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_pingcap_kvproto//pkg/brpb",
        "@com_github_pingcap_kvproto//pkg/import_sstpb",
        "@com_github_pingcap_kvproto//pkg/kvrpcpb",
        "@com_github_pingcap_kvproto//pkg/metapb",
        "@com_github_pkg_errors//:errors",
        "@com_github_stretchr_testify//require",
        "@com_github_tikv_pd_client//clients/router",
        "@org_golang_x_exp//slices",
        "@org_uber_go_goleak//:goleak",
    ],
)
